export JAVA_HOME="/usr/java/jdk1.8.0_131"
export CLASSPATH="/usr/java/jdk1.8.0_131/lib"
export JRE_HOME="/usr/java/jdk1.8.0_131/jre"
export PATH=$JAVA_HOME/bin:$PATH
cd /opt/rhino-web/rhino-web-view/
APP_NAME='rhino-web-view'
command='nohup java -Xms512m -Xmx512m -jar rhino-web-view-0.0.1-SNAPSHOT.jar'
log_file_url="logs/log.log"
pid_file="rhino-web-view.pid"
log_path="logs"
start(){
    if [ "$log_file_url" != "" ]; then
        echo "STARTING $APP_NAME ....."
        exec $command  > "$log_file_url" 2>&1 &
        echo $! > "$pid_file"
    else
        echo "STARTING $APP_NAME ....."
        exec $command &
        echo $! > "$pid_file" &
    fi
}
stop(){
    echo "STOPING $APP_NAME ....."
    PID=$(cat "$pid_file")
    kill -9 $PID
}
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        printf 'Usage: %s {start|stop|restart}\n'
        exit 1
        ;;
esac
